<template>
  <div id="VideoHome">
      <!-- 推荐 -->
        <div class="hot">
            <p class="title">热门推荐</p>
            <div class="lb">
                <el-carousel :interval="4000" width="600px" height="330px" indicator-position="outside">
                    <el-carousel-item v-for="(img,i) in scorll_img" :key="i">
                        <img :src="img">
                    </el-carousel-item>
                </el-carousel>
            </div>
            <div class="moves">
                <div class="move" v-for="(video,index) in videos" :key="index" @click="playVideo(video)">
                    <p @mouseenter="downSynopsis()" @mouseleave="upSynopsis()">简介</p>
                    <div class="mask" @mouseenter="downSynopsis()" @mouseleave="upSynopsis()">
                        <div class="description">&nbsp;&nbsp;{{video.description}}</div>
                    </div>
                    <img :src="file_path+video.videoCoverPic" @mouseenter="upInfo()">
                    <span class="title_init">{{video.videoTitle}}</span>
                    <div class="move_info" @mouseenter="upInfo()" @mouseleave="downInfo()">
                        <span class="move_title">{{video.videoTitle}}</span>
                        <span class="move_name">作者：{{video.videoAuthor}}</span>
                        <span class="move_count">播放量：{{video.numberOfHits}}</span>
                    </div>
                </div>
            </div>
        </div>
  </div>
</template>

<script>
import video_url from './url'
import file_path from './file_url'

export default {
    data(){
        return{
            url: video_url[0].url,
            file_path: file_path[0],
            videos:[],
            scorll_img:[],
        }
    },
    methods:{
        downSynopsis(){
            let title_init_element = event.target.parentNode.children[3];
            let mask_element = event.target.parentNode.children[1];

            $(title_init_element).stop().hide();
            $(mask_element).stop().slideDown(200);
        },
        upSynopsis(){
            let title_init_element = event.target.parentNode.children[3];
            let mask_element = event.target.parentNode.children[1];

            $(mask_element).stop().slideUp(200);
            $(title_init_element).stop().show();
        },
        upInfo(){
            let title_init_element = event.target.parentNode.children[3];
            let move_info_element = event.target.parentNode.children[4];
            let moves = event.target.parentNode.parentNode.children;

            for(let i=0; i<moves.length; i++){
                if(moves[i].children[3] != title_init_element){
                    $(moves[i].children[4]).stop().hide();
                    $(moves[i].children[3]).stop().show();
                }
            }

            $(title_init_element).stop().hide();
            $(move_info_element).stop().show();
        },
        downInfo(){
            let title_init_element = event.target.parentNode.children[3];
            let move_info_element = event.target.parentNode.children[4];

            $(move_info_element).stop().hide();
            $(title_init_element).stop().show();
        },
        playVideo(video){
            const { href } = this.$router.resolve({
                path:"/playVideo",
                query:{
                    id: video.id,
                }
			});
			window.open(href, '_blank');
        },
    },
    created(){
        this.$axios({
            url: this.url,
        }).then(res => {
            this.videos = res.data;
            for(let i=0;i<this.videos.length;i++){
                if(i>=3) break;
                this.scorll_img[i] = this.file_path+this.videos[i].videoCoverPic;
            }
        })
    },
    
}
</script>

<style>
    /* 热门推荐 */
    .hot{
        position: relative;
        width: 1350px;
        height: 500px;
        margin-left: 100px;
        margin-bottom: 30px;

        border-bottom: 1px solid #ddd;
    }
    .hot .title{
        width: 1250px;
        height: 40px;
        margin-top: 10px;
        margin-left: 50px;
        padding-left: 1.5%;
        border-bottom: 2px solid #ddd;

        font-size: 25px;
        line-height: 40px;
        font-weight: bold;
        letter-spacing: 2px;
        color: #409eff;
    }
    .hot .lb{
        position: absolute;
        width: 600px;
        height: 360px;
        top: 100px;
        left: 70px;
        overflow: hidden;
    }
    .hot .lb img{
        width: 600px;
        height: 360px;
    }
    .el-carousel__item h3 {
        color: #475669;
        font-size: 18px;
        opacity: 0.75;
        line-height: 300px;
        margin: 0;
    }
    .el-carousel__item:nth-child(2n) {
        background-color: #99a9bf;
    }
    .el-carousel__item:nth-child(2n+1) {
        background-color: #d3dce6;
    }

    .hot .moves{
        position: absolute;
        width: 550px;
        height: 400px;
        top: 80px;
        right: 50px;
    }
    .hot .move{
        position: relative;
        width: 170px;
        height: 120px;
        border-radius: 3px;
        /* background-color: green; */
        float: left;
        margin-left: 10px;
        margin-top: 55px;
        
    }
    .hot .move p{
        width: 170px;
        height: 20px;
        background-color: #333;
        opacity: .95;
        color: rgb(255, 255, 255);
        border-radius: 3px;
        margin-top: -20px;
        cursor: pointer;

        font-size: 14px;
        text-align: center;
        line-height: 20px;
        letter-spacing: 5px;
    }
    .hot .move .mask{
        position: absolute;
        display: none;
        width: 170px;
        height: 120px;
        background-color: #333;
        opacity: .8;
        z-index: 5;
        top: 0;
        left: 0;
    }
    .hot .move .mask .description{
        width: 130px;
        height:110px;
        margin-left: 15px;
        border-radius: 0.5rem;
        line-height: 18px;
        user-select: none;
        padding: 6px 5px;
        font-size: 12px;
        font-weight: bold;
        letter-spacing: 1px;
        color: #fff;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 6;
        -webkit-box-orient: vertical;
    }
    .hot .move img{
        position: absolute;
        width: 170px;
        height: 120px;
        border-radius: 5px;
        top: 0;
        left: 0;
    }
    .hot .move .move_info{
        display: none;
        position: absolute;
        width: 170px;
        height: 120px;
        bottom: 0px;
        left: 0;
        background-color: #333;
        opacity: .8;
        cursor: pointer;
    }
    .hot .move .title_init{
        position: absolute;
        width: 160px;
        height: 25px;
        bottom: 0;
        padding-left: 5px;
        padding-right: 5px;

        font-size: 15px;
        line-height: 25px;
        color: #fff;
        z-index: 5;

        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 1;
        -webkit-box-orient: vertical;
    }
    .hot .move .move_info .move_title{
        position: absolute;
        width: 150px;
        height: 50px;
        top: 0;
        padding-left: 10px;

        font-size: 15px;
        line-height: 25px;
        color: #fff;
        z-index: 5;

        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
    }
    .hot .move .move_info .move_name,.hot .move .move_info .move_count{
        position: absolute;
        width: 150px;
        height: 30px;
        padding-left: 5px;
        color: #fff;
        left: 5px;
        font-size: 10px;
    }
    .hot .move .move_info .move_name{
        top: 60px;
    }
    .hot .move .move_info .move_count{
        top: 90px;
    }
</style>